﻿using MyTodo.Common.Models;
using MyTodo.Extensions;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyTodo.ViewModels;

public class SettingViewModel : BindableBase
{

    private readonly IRegionManager _regionManager;

    public SettingViewModel(IRegionManager regionManager)
    {
        NavigateCommand = new DelegateCommand<MenuBar>(Navigate);
        MenuBars = new ObservableCollection<MenuBar>();
        CreateMenuBar();
        _regionManager = regionManager;
    }
    public DelegateCommand<MenuBar> NavigateCommand { get; private set; }
    public ObservableCollection<MenuBar>? MenuBars { get; set; }
    private void CreateMenuBar()
    {
        MenuBars?.Add(new MenuBar() { Icon = "Palette", Title = "个性化", NameSpace = "SkinView" });
        MenuBars?.Add(new MenuBar() { Icon = "Cog", Title = "系统设置", NameSpace = "" });
        MenuBars?.Add(new MenuBar() { Icon = "Information", Title = "关于更多", NameSpace = "AboutView" });
   }
    private void Navigate(MenuBar menuBar)
    {
        if (menuBar == null || string.IsNullOrWhiteSpace(menuBar.NameSpace))
            return;
        _regionManager.RequestNavigate(PrismManager.SettingsViewRegionName, menuBar.NameSpace);
    }

}
